<!DOCTYPE html>



  


<html class="theme-next gemini use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">



  
  
    
    
  <script src="/lib/pace/pace.min.js?v=1.0.2"></script>
  <link href="/lib/pace/pace-theme-minimal.min.css?v=1.0.2" rel="stylesheet">







<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.2" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Robin, 神话" />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.2" />






<meta name="description" content="官方文档   Q1：我的应用为何要使用通用链接？  我们的应用有很多分享到微信、QQ等第三方平台的内容，使用过程中，为了让用户在分享到微信的网页里面点击某个链接或者打开按钮直接转到我们的app，盯上了这个iOS 9之后才有的系统级的功能，他就是 Universal Links。虽然说通用链接并不是专门为这种设计的，但是要实现我上面说的 微信跳转到你的app ，它还是很方便的。  Q2：为何不用s">
<meta property="og:type" content="article">
<meta property="og:title" content="iOS通用链接 By Winson">
<meta property="og:url" content="http://robinchan.cn/2017/07/26/iOSSupportUniversalLinksByWinson/index.html">
<meta property="og:site_name" content="神话先生">
<meta property="og:description" content="官方文档   Q1：我的应用为何要使用通用链接？  我们的应用有很多分享到微信、QQ等第三方平台的内容，使用过程中，为了让用户在分享到微信的网页里面点击某个链接或者打开按钮直接转到我们的app，盯上了这个iOS 9之后才有的系统级的功能，他就是 Universal Links。虽然说通用链接并不是专门为这种设计的，但是要实现我上面说的 微信跳转到你的app ，它还是很方便的。  Q2：为何不用s">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/6067780-bfbf1d20b36064e7.gif?imageMogr2/auto-orient/strip">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/6067780-a187a924f6edd604.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/6067780-e5aab7f027006d2a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/6067780-aeda0e60f1172991.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/6067780-16b4c4c8a3a0dce4.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/6067780-5f5701fbc4343255.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/6067780-57223885809e51b3.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/6067780-eed9c6467802ecfc.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/6067780-ab9401bb05fc5711.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/6067780-08ed38284d1f1fbc.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/6067780-744b731c22db8998.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/6067780-200605e98ee85929.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/6067780-2b8eb327d95c3ce8.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/6067780-c7569ec3df79fbd7.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/6067780-5daaab263bef97dd.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/6067780-4de512d9ad573fcf.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/6067780-211d769bd04de8b6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/6067780-a10591357e4550f6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:updated_time" content="2017-07-26T06:55:34.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="iOS通用链接 By Winson">
<meta name="twitter:description" content="官方文档   Q1：我的应用为何要使用通用链接？  我们的应用有很多分享到微信、QQ等第三方平台的内容，使用过程中，为了让用户在分享到微信的网页里面点击某个链接或者打开按钮直接转到我们的app，盯上了这个iOS 9之后才有的系统级的功能，他就是 Universal Links。虽然说通用链接并不是专门为这种设计的，但是要实现我上面说的 微信跳转到你的app ，它还是很方便的。  Q2：为何不用s">
<meta name="twitter:image" content="http://upload-images.jianshu.io/upload_images/6067780-bfbf1d20b36064e7.gif?imageMogr2/auto-orient/strip">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '5.1.2',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":12,"b2t":false,"scrollpercent":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn"}},
    duoshuo: {
      userId: 'undefined',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://robinchan.cn/2017/07/26/iOSSupportUniversalLinksByWinson/"/>





  <title>iOS通用链接 By Winson | 神话先生</title>
  





  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?d4cc25ad364a56f93303bcfa0d03ab51";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>




</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">神话先生</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">洗涤灵魂，以阳光之气待人</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-commonweal">
          <a href="/404.html" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-heartbeat"></i> <br />
            
            公益404
          </a>
        </li>
      
        
        <li class="menu-item menu-item-high">
          <a href="/high" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-bolt"></i> <br />
            
            嗨起来
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://robinchan.cn/2017/07/26/iOSSupportUniversalLinksByWinson/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="神话先生">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="http://7sbydq.com1.z0.glb.clouddn.com/binMythAvatar">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="神话先生">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">iOS通用链接 By Winson</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-07-26T13:44:37+08:00">
                2017-07-26
              </time>
            

            

            
          </span>

          

          
            
            <!--noindex-->
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2017/07/26/iOSSupportUniversalLinksByWinson/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count hc-comment-count" data-xid="2017/07/26/iOSSupportUniversalLinksByWinson/" itemprop="commentsCount"></span>
                </a>
              </span>
              <!--/noindex-->
            
          

          
          
             <span id="/2017/07/26/iOSSupportUniversalLinksByWinson/" class="leancloud_visitors" data-flag-title="iOS通用链接 By Winson">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读&#58;</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          
            <span class="post-meta-divider">|</span>
            <span class="page-pv"><i class="fa fa-file-o"></i>
            <span class="busuanzi-value" id="busuanzi_value_page_pv" ></span>
            </span>
          

          
            <div class="post-wordcount">
              
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数&#58;</span>
                
                <span title="字数">
                  2,797
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">时长 &asymp;</span>
                
                <span title="时长">
                  10
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p><img src="http://upload-images.jianshu.io/upload_images/6067780-bfbf1d20b36064e7.gif?imageMogr2/auto-orient/strip" alt=""></p>
<p><a href="https://developer.apple.com/library/content/documentation/General/Conceptual/AppSearch/UniversalLinks.html#//apple_ref/doc/uid/TP40016308-CH12-SW1" target="_blank" rel="external">官方文档 </a></p>
<blockquote>
<p>Q1：我的应用为何要使用通用链接？</p>
</blockquote>
<p>我们的应用有很多分享到微信、QQ等第三方平台的内容，使用过程中，为了让用户在分享到微信的网页里面点击某个链接或者打开按钮直接转到我们的app，盯上了这个iOS 9之后才有的系统级的功能，他就是 Universal Links。虽然说通用链接并不是专门为这种设计的，但是要实现我上面说的 微信跳转到你的app ，它还是很方便的。</p>
<blockquote>
<p>Q2：为何不用scheme？</p>
</blockquote>
<p>scheme的方式是不允许从微信或者其他app跳转到你的app的，除非微信或者其他app的白名单里面有你的app的scheme，这好像也不是好多文章里面说的微信禁用了scheme，微信都不知道你的scheme怎么给你跳转到你的应用呢 。（个人理解）</p>
<p>我把它分成三部分吧（Developer Settings）</p>
<ol>
<li><a href="#1. Developer Settings"><strong>Developer Settings</strong> （开发者中心配置）</a></li>
<li><a href="#2. HTTPS Settings"><strong>HTTPS Settings</strong>（服务器配置）</a></li>
<li><a href="#3. Xcode Settings"><strong>Xcode Settings</strong>（Xcode配置）</a></li>
</ol>
<a id="more"></a>
<p><span id="1. Developer Settings"></span></p>
<h2 id="Developer-Settings"><a href="#Developer-Settings" class="headerlink" title="Developer Settings"></a>Developer Settings</h2><p>首先，需要在开发者中心开启Associated Domains功能，具体操作是：</p>
<p>在 <strong>App IDs</strong> 选择你要修改的 <strong>App ID</strong> ；<br><img src="http://upload-images.jianshu.io/upload_images/6067780-a187a924f6edd604.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt=""><br>点击要修改的 <strong>App ID</strong>，在列表中勾选 <strong>Associated Domains</strong> ；<br><img src="http://upload-images.jianshu.io/upload_images/6067780-e5aab7f027006d2a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt=""><br>在弹出框点确定，这个警告是告诉你，你如果启用该功能，就相当于编辑了这个 <strong>App ID</strong>，那么你现有的用该 <strong>App ID</strong> 生成的描述文件就得重新生成并导入至 <strong>Xcode</strong> 中了；<br><img src="http://upload-images.jianshu.io/upload_images/6067780-aeda0e60f1172991.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt=""><br>点击确定后，你会发现 <strong>Associated Domains</strong> 可用了；<br><img src="http://upload-images.jianshu.io/upload_images/6067780-16b4c4c8a3a0dce4.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt=""><br>点击描述文件，发现失效了，那是因为你编辑过生成该描述文件用到的 <strong>App ID</strong>，不急，编辑它就是了；<br><img src="http://upload-images.jianshu.io/upload_images/6067780-5f5701fbc4343255.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt=""><br>编辑描述文件，只需要重新勾选 <strong>App ID</strong> 即可，然后保存的描述文件又变成有效的了。下图注释中说的很明确了，<strong>Download</strong> 该描述文件，双击安装即可。<br><img src="http://upload-images.jianshu.io/upload_images/6067780-57223885809e51b3.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt=""><br>开发跟发布的描述文件都重新生成并下载安装之后，开发者中心的配置就完成了。</p>
<p><span id="2. HTTPS Settings"></span></p>
<h2 id="HTTPS-Settings"><a href="#HTTPS-Settings" class="headerlink" title="HTTPS Settings"></a>HTTPS Settings</h2><h3 id="有一个注册的通过-SSL-访问的域名（HTTPS）"><a href="#有一个注册的通过-SSL-访问的域名（HTTPS）" class="headerlink" title="有一个注册的通过 SSL 访问的域名（HTTPS）"></a>有一个注册的通过 <strong>SSL</strong> 访问的域名（<strong>HTTPS</strong>）</h3><p>假设你的域名为 <strong>domain</strong> ，例如：<em>www.xxx.com</em> 或 <em>xxx.com</em> 或 <em>xxx.xxx.com</em> 都能当做是域名，具体看你后台怎么给你配，我这里称之为 <strong>domain</strong>，<strong>domain</strong> 代表上述那几种域名。</p>
<h3 id="支持上传一个-JSON-文件到你的域名"><a href="#支持上传一个-JSON-文件到你的域名" class="headerlink" title="支持上传一个 JSON 文件到你的域名"></a>支持上传一个 <strong>JSON</strong> 文件到你的域名</h3><p>用文本编辑器写一个 <strong>JSON</strong> ，该 <strong>JSON</strong> 的格式是：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line">&#123;</div><div class="line">    &quot;applinks&quot;: &#123;</div><div class="line">        &quot;apps&quot;: [],</div><div class="line">        &quot;details&quot;: [</div><div class="line">            &#123;</div><div class="line">                &quot;appID&quot;: &quot;TeamID.BundleIdentifier&quot;,</div><div class="line">                &quot;paths&quot;: [ &quot;*&quot; ]</div><div class="line">            &#125;</div><div class="line">        ]</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<p>这个 <strong>JSON</strong> 最好去 <a href="https://developer.apple.com/library/content/documentation/General/Conceptual/AppSearch/UniversalLinks.html#//apple_ref/doc/uid/TP40016308-CH12-SW1" target="_blank" rel="external">官方文档</a> 去复制，我之前复制了一片博客上的，就是错的。<br> 上面的 <strong>appID</strong> 的组成结构是 <strong>TeamID.BundleIdentifier</strong></p>
<ol>
<li><strong>TeamID</strong> 可以去开发者中心的 <strong>Account -&gt; Membership</strong> 下去找。如图：<br><img src="http://upload-images.jianshu.io/upload_images/6067780-eed9c6467802ecfc.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt=""></li>
<li><strong>BundleIdentifier</strong> 就是你应用的 <strong>Bundle Identifier</strong>，如图：<br><img src="http://upload-images.jianshu.io/upload_images/6067780-ab9401bb05fc5711.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt=""><br>这个 <strong>JSON</strong> 其他 <strong>key</strong> 的作用我就不过多赘述了，具体看官方文档，<strong> paths</strong> 我这里是用了 <strong>*</strong>，代表支持该域名下的所有链接跳转至 <strong>App</strong>。</li>
<li>编辑好该 <strong>JSON</strong> 后，保存，命名为：<code>apple-app-site-association</code>，注意，这里不能给该文件冠以 <code>.json</code>之类的后缀。如图：<br><img src="http://upload-images.jianshu.io/upload_images/6067780-08ed38284d1f1fbc.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt=""></li>
<li>将保存好的 <strong>JSON</strong> 文件 <code>apple-app-site-association</code>上传至HTTPS服务器域名的 <strong>根目录</strong> 或者根目录下的<code>.well-known</code>文件夹下。例如：<a href="https://domain/apple-app-site-association" target="_blank" rel="external">https://domain/apple-app-site-association</a> 或者 <a href="https://domain/.well-known/apple-app-site-association，" target="_blank" rel="external">https://domain/.well-known/apple-app-site-association，</a> 其中 <strong>domain</strong> 就是你的域名，上面已经概述过。</li>
</ol>
<h3 id="能通过-GET-请求访问该域名下的-JSON"><a href="#能通过-GET-请求访问该域名下的-JSON" class="headerlink" title="能通过 GET 请求访问该域名下的 JSON"></a>能通过 <strong>GET</strong> 请求访问该域名下的 <strong>JSON</strong></h3><p>上传好 <strong>JSON</strong> 文件后，最简单的办法是通过浏览器访问该文件，如果能得到该 <strong>JSON</strong> 内容，说明已经可以访问该文件。如图：<br><img src="http://upload-images.jianshu.io/upload_images/6067780-744b731c22db8998.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="我这浏览器装了json插件，没装的效果可能不是上图所示。"><br>有的博客写可以去苹果的一个 <a href="https://search.developer.apple.com/appsearch-validation-tool/" target="_blank" rel="external">检测网站</a> 检测是否可用，我反正是每次都失败了，纠结了我好久。其实，用浏览器能访问到该json说明也是成功了，别纠结。<br>至此，web的配置就完成了。</p>
<p><span id="3. Xcode Settings"></span></p>
<h2 id="Xcode-Settings"><a href="#Xcode-Settings" class="headerlink" title="Xcode Settings"></a>Xcode Settings</h2><h3 id="工程配置"><a href="#工程配置" class="headerlink" title="工程配置"></a>工程配置</h3><p><strong>Targets -&gt; Capabilities -&gt; Associated Domains</strong><br><img src="http://upload-images.jianshu.io/upload_images/6067780-200605e98ee85929.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt=""><br>这里的操作就是添加 <strong>Domains</strong>，具体写 <strong>applinks:domain</strong>，这里的 <strong>domain</strong> 跟上一步 <strong>Web Settings</strong> 里面的 <strong>domain</strong> 是一致的。<br><code>假设你的域名为 domain ，例如：www.xxx.com 或 xxx.com 或 xxx.xxx.com 都能当做是域名，具体看你后台怎么给你配，我这里称之为 domain，domain 代表上述那几种域名。</code><br>这里开启了 <strong>Associated Domains</strong>  功能后，你的工程会自动创建一个 <strong>.entitlements</strong> 文件，如图：<br><img src="http://upload-images.jianshu.io/upload_images/6067780-2b8eb327d95c3ce8.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt=""><br>到这里的时候，你的通用链接基本打通了。你可以通过简单的方法来测试一下。<br>我的测试方法是：</p>
<ol>
<li>删除已安装的app，重新安装；</li>
<li>待程序安装好后，打开备忘录，在备忘录里面随便输入一个带域名的链接，比如：<a href="https://domain/xxx，" target="_blank" rel="external">https://domain/xxx，</a> 点击右上角完成按钮；</li>
<li>长按该链接，如果已接通通用链接，底部弹出框会多出一栏，显示“在xxx中打开”，其中这个xxx就是你应用的名字。如图：<br><img src="http://upload-images.jianshu.io/upload_images/6067780-c7569ec3df79fbd7.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt=""><br>说明，已经接通了。<h3 id="AppDelegate-m-接收并处理回调"><a href="#AppDelegate-m-接收并处理回调" class="headerlink" title="AppDelegate.m 接收并处理回调"></a>AppDelegate.m 接收并处理回调</h3>通过浏览器或者别的app里面的网页内点击你的通用链接跳转至你的app之后，会执行这个方法：<br>-application:continueUserActivity:restorationHandler:<br>以下是我的代码：<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div></pre></td><td class="code"><pre><div class="line"> - (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler &#123;</div><div class="line">    if ([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) &#123;</div><div class="line">        NSURL *webUrl = userActivity.webpageURL;</div><div class="line">        NSLog(@&quot;host = %@&quot;, webUrl.host);</div><div class="line">        NSString *urlString = webUrl.absoluteString;</div><div class="line">        NSArray *arr = [urlString componentsSeparatedByString:@&quot;xxx&quot;];</div><div class="line">        if (arr.count == 2) &#123;</div><div class="line">            if ([[arr lastObject] length] &gt; 0) &#123;</div><div class="line">                NSString *paraString = [arr lastObject];</div><div class="line">                NSString *schemeStr = @&quot;xxxxxxx&quot;;</div><div class="line">                if ([paraString hasPrefix:schemeStr]) &#123;</div><div class="line">                    NSLog(@&quot;接收到了&quot;);</div><div class="line">                    NSLog(@&quot;root = %@&quot;, self.window.rootViewController);</div><div class="line">                    id rootVC = self.window.rootViewController;</div><div class="line">                    if ([rootVC isKindOfClass:[LoginNVC class]]) &#123;</div><div class="line">                        NSLog(@&quot;未登录，请先登录&quot;);</div><div class="line">                    &#125; else &#123;</div><div class="line">                        NSLog(@&quot;已登录直接跳转至指定页面&quot;);</div><div class="line">                        [self gotoDiffrentVCWithUrl:[NSURL URLWithString:paraString]];</div><div class="line">                    &#125;</div><div class="line">                &#125;</div><div class="line">            &#125;</div><div class="line">        &#125;</div><div class="line">        return YES;</div><div class="line">    &#125; else &#123;</div><div class="line">        return NO;</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
</li>
</ol>
<p>代码写的比较仓促，不用纠结，里面的关键key我也用xxx来代替了，主要看你后台的通用链接的参数啊什么的有没有指定规则吧，比如我这里都是遵循制定好的规则来跳指定页面的。</p>
<h2 id="最重要的几点（坑😤）"><a href="#最重要的几点（坑😤）" class="headerlink" title="最重要的几点（坑😤）"></a>最重要的几点（坑😤）</h2><h3 id="domain-不能跟你的网页的-host-相同"><a href="#domain-不能跟你的网页的-host-相同" class="headerlink" title="domain 不能跟你的网页的  host  相同"></a>domain 不能跟你的网页的  host  相同</h3><p>我配置好了之后，就来在后台写了一个网页，网页的 <strong>host</strong> 用的是 <strong>domain</strong>，网页里面加了几个超链接，超链接的地址的 <strong>host</strong> 用的是 <strong>domain</strong>，然后分享到微信，在微信打开的网页里面点击我写好的几个超链接，发现，天哪，居然直接在微信的网页内继续打开了，并没有跳转到我的 <strong>app</strong>。用 <strong>Safari </strong> 打开，居然也是在 <strong>Safari </strong> 中继续打开网页了，没有跳转至我的 <strong>app</strong>。崩溃了😖……然后纠结了好久，是我哪里没配置好吗，是不是文件的 <strong>JSON</strong>有问题？是不是哪里出问题了？答案就是：<strong>domain 不能跟你的网页的 host 相同</strong>。</p>
<blockquote>
<p>比如：微信打开你的网页，网页内有个“打开app”按钮，你点击“打开app”按钮，期望是跳到你的app。<br>毋庸置疑，“打开app”这个操作最终触发的链接是你上面配置好的 <strong>domain</strong> 的地址，那么这个时候，你这个网页的地址就不应该是带有 <strong>domain</strong> 的地址了。如果你网页是在 <strong>domain</strong> 下，而且你的“打开app”的地址也在 <strong>domain</strong> 下，那么就不会跳转到你的 <strong>app</strong>。我也不知道是为什么，理解的浅，但实际上这样就是不行。例子：<br>网页地址：<a href="http://host/xxx" target="_blank" rel="external">http://host/xxx</a><br>“打开app”地址：<a href="https://domain/xxx?xxx=xxx" target="_blank" rel="external">https://domain/xxx?xxx=xxx</a><br>这里的host如果等于domain，就是我上面说的那种情况，直接在网页内打开了。如果host不等于domain，完美跳转至你的app。<br>当然，“打开app”这个操作实际上并没有那么简单。实际上还要多重判断。如果你并未安装该app，那么跳转到下载页面。如果你安装了该app，直接在触发这个domain链接的时候就跳到你的app了。</p>
</blockquote>
<h3 id="iOS-会记录你的用户习惯"><a href="#iOS-会记录你的用户习惯" class="headerlink" title="iOS  会记录你的用户习惯"></a>iOS  会记录你的用户习惯</h3><p>iOS 10下用通用链接跳转至你的app的时候，假设这里是微信网页里面点击了“打开app”跳转至你的应用，那么跳到你的应用的时候，你的应用顶部的statusbar左上角会出现“返回至微信”按钮，右上角会出现“用Safari打开xxx”。如下图：<br><img src="http://upload-images.jianshu.io/upload_images/6067780-5daaab263bef97dd.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt=""><br>当你点击了右上角的这个按钮的时候，会跳转至Safari打开你的通用链接，iOS系统会记录你这个操作，认为你想在网页内打开你的domain下的通用链接，会导致你之后点击你的通用链接的时候，直接在Safari中打开了，而不是跳到你的app。<br>烦！<br>我测试了一下凤凰新闻和网易新闻，从微信跳转至他们的app之后，发现凤凰新闻的右上角的那个openInSafari可以点击并用Safari打开到指定页面，再次在微信内点击凤凰新闻的打开app按钮时，就直接在微信网页内打开了，而不是跳转到你的app。网易新闻就怪异了，点击微信内网易新闻的打开app按钮跳转到网易新闻app时，右上角的openInSafari是不可点的！好奇怪。<br>那么上面说的凤凰新闻一旦点击了右上角之后，后续在微信的凤凰新闻网页内打开app怎么再去跳转至凤凰新闻app呢？如图：<br><img src="http://upload-images.jianshu.io/upload_images/6067780-4de512d9ad573fcf.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="微信内点击打开app"><br><img src="http://upload-images.jianshu.io/upload_images/6067780-211d769bd04de8b6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="Safari中打开"><br><img src="http://upload-images.jianshu.io/upload_images/6067780-a10591357e4550f6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="下拉点击打开"><br>依照凤凰新闻网页的提示一步步操作，到最后点击Safari中右上角的打开按钮时，那么iOS系统则再次认为用户点击凤凰新闻的通用链接时是想打开凤凰新闻的app而不是在网页内浏览。那么后续的分享至微信的凤凰新闻的网页内点击打开app的操作就会又是跳转到凤凰新闻app了。<br>我这里并没按照凤凰新闻的做法，而是研究了一下网易新闻到底是怎么禁掉右上角的openInSafari按钮的。就是我不给用户openInSafari的选择。<br>直接上代码：</p>
<ul>
<li><p>在MainTBC监听UIApplicationDidBecomeActiveNotification</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(becomeActive) name:UIApplicationDidBecomeActiveNotification object:nil];</div></pre></td></tr></table></figure>
</li>
<li><p>遍历statusbar子视图，找到UIStatusBarOpenInSafariItemView并禁用它</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div></pre></td><td class="code"><pre><div class="line"> - (void)becomeActive &#123;</div><div class="line">    NSLog(@&quot;didBecomeActive&quot;);</div><div class="line">    UIView *statusBar = [[UIApplication sharedApplication] valueForKey:@&quot;statusBar&quot;];</div><div class="line">    NSLog(@&quot;statusBar.subviews = %@&quot;, statusBar.subviews);</div><div class="line">    //遍历子视图，找到右侧用Safari打开视图，禁用它。</div><div class="line">    for (UIView *subView in statusBar.subviews) &#123;</div><div class="line">        NSLog(@&quot;subView.subviews = %@&quot;, subView.subviews);</div><div class="line">        for (UIView *aView in subView.subviews) &#123;</div><div class="line">            NSString *aViewClass = NSStringFromClass([aView class]);</div><div class="line">            NSLog(@&quot;aViewClass = %@&quot;, aViewClass);</div><div class="line">            if ([aViewClass isEqualToString:@&quot;UIStatusBarOpenInSafariItemView&quot;]) &#123;</div><div class="line">                aView.userInteractionEnabled = NO;</div><div class="line">                break;</div><div class="line">            &#125;</div><div class="line">        &#125;</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
</li>
</ul>
<p>好吧，禁用掉了右上角进入Safari的按钮，不知道这样好不好，我一个朋友跟我说这样不好吧，暂且这样吧，其实可能还是有bug的，网易不知道是怎么做的，我做的只是在didbecomeactive里面的时候去遍历statusbar。</p>
<h2 id="最后"><a href="#最后" class="headerlink" title="最后"></a>最后</h2><p>还是我写在开头的那句话 <strong><a href="https://developer.apple.com/library/content/documentation/General/Conceptual/AppSearch/UniversalLinks.html#//apple_ref/doc/uid/TP40016308-CH12-SW1" target="_blank" rel="external">官方文档 </a></strong></p>
<h2 id="最后的最后"><a href="#最后的最后" class="headerlink" title="最后的最后"></a>最后的最后</h2><p>如果有哪里写错了，欢迎指正，谢谢！</p>
<p>作者：winsonGali<br>链接：<a href="http://www.jianshu.com/p/eddc4365dcde" target="_blank" rel="external">http://www.jianshu.com/p/eddc4365dcde</a><br>來源：简书<br>著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。</p>

      
    </div>
    
    
    

    

    

    
      <div>
        <ul class="post-copyright">
  <li class="post-copyright-author">
    <strong>本文作者：</strong>
    神话先生
  </li>
  <li class="post-copyright-link">
    <strong>本文链接：</strong>
    <a href="http://robinchan.cn/2017/07/26/iOSSupportUniversalLinksByWinson/" title="iOS通用链接 By Winson">http://robinchan.cn/2017/07/26/iOSSupportUniversalLinksByWinson/</a>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>
    本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/3.0/" rel="external nofollow" target="_blank">CC BY-NC-SA 3.0</a> 许可协议。转载请注明出处！
  </li>
</ul>

      </div>
    

    <footer class="post-footer">
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/07/25/reactnativeblog/" rel="next" title="react native开源">
                <i class="fa fa-chevron-left"></i> react native开源
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/08/03/strongMemory/" rel="prev" title="记忆力">
                记忆力 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div id="hypercomments_widget"></div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          
            <img class="site-author-image" itemprop="image"
              src="http://7sbydq.com1.z0.glb.clouddn.com/binMythAvatar"
              alt="神话先生" />
          
            <p class="site-author-name" itemprop="name">神话先生</p>
            <p class="site-description motion-element" itemprop="description">分享生活，分享技术</p>
        </div>

        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
            
              <a href="/archives/">
            
                <span class="site-state-item-count">32</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-categories">
              
                <span class="site-state-item-count">3</span>
                <span class="site-state-item-name">分类</span>
              
            </div>
          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">19</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="mailto:me@robinchan.cn" target="_blank" title="E-Mail">
                  
                    <i class="fa fa-fw fa-envelope"></i>E-Mail</a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://github.com/jasparchan" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>GitHub</a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://weibo.com/cweibin" target="_blank" title="Weibo">
                  
                    <i class="fa fa-fw fa-weibo"></i>Weibo</a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://facebook.com/jesparchan" target="_blank" title="FB">
                  
                    <i class="fa fa-fw fa-facebook"></i>FB</a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://instagram.com/robinchan758" target="_blank" title="Instagram">
                  
                    <i class="fa fa-fw fa-instagram"></i>Instagram</a>
              </span>
            
          
        </div>

        
        
          <div class="cc-license motion-element" itemprop="license">
            <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" class="cc-opacity" target="_blank">
              <img src="/images/cc-by-nc-sa.svg" alt="Creative Commons" />
            </a>
          </div>
        

        
        
          <div class="links-of-blogroll motion-element links-of-blogroll-inline">
            <div class="links-of-blogroll-title">
              <i class="fa  fa-fw fa-globe"></i>
              iOS Link
            </div>
            <ul class="links-of-blogroll-list">
              
                <li class="links-of-blogroll-item">
                  <a href="https://winsongali.github.io" title="Winson" target="_blank">Winson</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://peiyan.club" title="慎独" target="_blank">慎独</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://qimizen.github.io" title="Qimi" target="_blank">Qimi</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://developer.apple.com/swift/blog" title="AppleSwiftBlog" target="_blank">AppleSwiftBlog</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://iosdevweekly.com" title="iosdevweekly" target="_blank">iosdevweekly</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://www.objccn.io" title="ObjC 中国" target="_blank">ObjC 中国</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://macshuo.com" title="MacTalk" target="_blank">MacTalk</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://onevcat.com" title="喵神" target="_blank">喵神</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://blog.devtang.com" title="唐巧" target="_blank">唐巧</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://zhowkev.in" title="Kevin" target="_blank">Kevin</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://limboy.me" title="Limboy" target="_blank">Limboy</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://blog.sunnyxx.com" title="sunnyxx" target="_blank">sunnyxx</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://blog.cnbang.net" title="bang's blog" target="_blank">bang's blog</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://gracelancy.com" title="Lancy" target="_blank">Lancy</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://coderyi.com" title="coderyi" target="_blank">coderyi</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://github.com/Aufree/trip-to-iOS/blob/master/Top-100.md" title="iOSTop100" target="_blank">iOSTop100</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="false" title="onmobile" target="_blank">onmobile</a>
                </li>
              
            </ul>
          </div>
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#Developer-Settings"><span class="nav-number">1.</span> <span class="nav-text">Developer Settings</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#HTTPS-Settings"><span class="nav-number">2.</span> <span class="nav-text">HTTPS Settings</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#有一个注册的通过-SSL-访问的域名（HTTPS）"><span class="nav-number">2.1.</span> <span class="nav-text">有一个注册的通过 SSL 访问的域名（HTTPS）</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#支持上传一个-JSON-文件到你的域名"><span class="nav-number">2.2.</span> <span class="nav-text">支持上传一个 JSON 文件到你的域名</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#能通过-GET-请求访问该域名下的-JSON"><span class="nav-number">2.3.</span> <span class="nav-text">能通过 GET 请求访问该域名下的 JSON</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Xcode-Settings"><span class="nav-number">3.</span> <span class="nav-text">Xcode Settings</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#工程配置"><span class="nav-number">3.1.</span> <span class="nav-text">工程配置</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#AppDelegate-m-接收并处理回调"><span class="nav-number">3.2.</span> <span class="nav-text">AppDelegate.m 接收并处理回调</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#最重要的几点（坑😤）"><span class="nav-number">4.</span> <span class="nav-text">最重要的几点（坑😤）</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#domain-不能跟你的网页的-host-相同"><span class="nav-number">4.1.</span> <span class="nav-text">domain 不能跟你的网页的  host  相同</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#iOS-会记录你的用户习惯"><span class="nav-number">4.2.</span> <span class="nav-text">iOS  会记录你的用户习惯</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#最后"><span class="nav-number">5.</span> <span class="nav-text">最后</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#最后的最后"><span class="nav-number">6.</span> <span class="nav-text">最后的最后</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy;  2015 &mdash; 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">神话先生</span>

  
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
    
      <span class="post-meta-item-text">总字数&#58;</span>
    
    <span title="总字数">
      21.8k
    </span>
  
</div>



        
<div class="busuanzi-count">
  <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv">
      <i class="fa fa-user"></i>
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
      
    </span>
  

  
    <span class="site-pv">
      <i class="fa fa-eye"></i>
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
      
    </span>
  
</div>








        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.2"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.2"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.2"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.2"></script>



  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.2"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.2"></script>


  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.2"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.2"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.2"></script>



  


  




	

		<script type="text/javascript">
		_hcwp = window._hcwp || [];

		_hcwp.push({widget:"Bloggerstream", widget_id: 98090, selector:".hc-comment-count", label: "{\%COUNT%\}" });

		
		_hcwp.push({widget:"Stream", widget_id: 98090, xid: "2017/07/26/iOSSupportUniversalLinksByWinson/"});
		

		(function() {
		if("HC_LOAD_INIT" in window)return;
		HC_LOAD_INIT = true;
		var lang = (navigator.language || navigator.systemLanguage || navigator.userLanguage || "en").substr(0, 2).toLowerCase();
		var hcc = document.createElement("script"); hcc.type = "text/javascript"; hcc.async = true;
		hcc.src = ("https:" == document.location.protocol ? "https" : "http")+"://w.hypercomments.com/widget/hc/98090/"+lang+"/widget.js";
		var s = document.getElementsByTagName("script")[0];
		s.parentNode.insertBefore(hcc, s.nextSibling);
		})();
		</script>

	












  





  

  
  <script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.4.js"></script>
  <script>AV.initialize("3ybo30xOd0PLReDkhqEeWOJR-gzGzoHsz", "94Cdf3fTsleQ0StzLDikoBAj");</script>
  <script>
    function showTime(Counter) {
      var query = new AV.Query(Counter);
      var entries = [];
      var $visitors = $(".leancloud_visitors");

      $visitors.each(function () {
        entries.push( $(this).attr("id").trim() );
      });

      query.containedIn('url', entries);
      query.find()
        .done(function (results) {
          var COUNT_CONTAINER_REF = '.leancloud-visitors-count';

          if (results.length === 0) {
            $visitors.find(COUNT_CONTAINER_REF).text(0);
            return;
          }

          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.get('url');
            var time = item.get('time');
            var element = document.getElementById(url);

            $(element).find(COUNT_CONTAINER_REF).text(time);
          }
          for(var i = 0; i < entries.length; i++) {
            var url = entries[i];
            var element = document.getElementById(url);
            var countSpan = $(element).find(COUNT_CONTAINER_REF);
            if( countSpan.text() == '') {
              countSpan.text(0);
            }
          }
        })
        .fail(function (object, error) {
          console.log("Error: " + error.code + " " + error.message);
        });
    }

    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();
      var query = new AV.Query(Counter);

      query.equalTo("url", url);
      query.find({
        success: function(results) {
          if (results.length > 0) {
            var counter = results[0];
            counter.fetchWhenSave(true);
            counter.increment("time");
            counter.save(null, {
              success: function(counter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(counter.get('time'));
              },
              error: function(counter, error) {
                console.log('Failed to save Visitor num, with error message: ' + error.message);
              }
            });
          } else {
            var newcounter = new Counter();
            /* Set ACL */
            var acl = new AV.ACL();
            acl.setPublicReadAccess(true);
            acl.setPublicWriteAccess(true);
            newcounter.setACL(acl);
            /* End Set ACL */
            newcounter.set("title", title);
            newcounter.set("url", url);
            newcounter.set("time", 1);
            newcounter.save(null, {
              success: function(newcounter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(newcounter.get('time'));
              },
              error: function(newcounter, error) {
                console.log('Failed to create');
              }
            });
          }
        },
        error: function(error) {
          console.log('Error:' + error.code + " " + error.message);
        }
      });
    }

    $(function() {
      var Counter = AV.Object.extend("Counter");
      if ($('.leancloud_visitors').length == 1) {
        addCount(Counter);
      } else if ($('.post-title-link').length > 1) {
        showTime(Counter);
      }
    });
  </script>



  
<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>


  

  

  

  

  
</body>
</html>
